import http from './axios'
import category from './modules/category'
import paper from './modules/paper'
import ques from './modules/ques'
import user from './modules/user'
import contest from './modules/contest'

const baseURL = http.baseURL

export default {
  baseURL,
  ...category,
  ...paper,
  ...ques,
  ...user,
  ...contest,
  commonResp (fn) {
    return function (resp) {
      let data = resp.data
      if (data.code === 1) {
        if (fn) { fn(true, data.data) }
      } else {
        if (fn) { fn(false, data.msg) }
      }
    }
  }
}
